//
//  WBBaseTableViewController.swift
//  SinaWeibo
//
//  Created by zhuangqianwei on 16/11/13.
//  Copyright © 2016年 zhuangqianwei. All rights reserved.
//

import UIKit

class WBBaseTableViewController: UITableViewController,WBVisitorLoginViewDelegate {

    //定义用户是否登录的标记
    
    var userLogin = WBUserAccountViewModel.shared.userLogin
    
    lazy var visitorView: WBVisitorLoginView = WBVisitorLoginView()
    
    //判断用户登录
    override func loadView() {
        
        if userLogin {
            //用户登录，准备好tableView
            super.loadView()
        }else{
            //用户没登录
            self.view = visitorView
            //设置代理
            visitorView.delegate = self
            //按钮的点击事件
            visitorView.loginBtn.addTarget(self, action: #selector(userWillLogin), for: .touchUpInside)
            visitorView.registerBtn.addTarget(self, action: #selector(userWillRegister), for: .touchUpInside)

            
        }
    }
    
    
    func userWillLogin() {
        let oauth = WBOAuthViewController()
//        self.navigationController?.pushViewController(oauth, animated: true)
        //这里用modal，打断了线性的操作用（modal，dismiss）
        let nav = UINavigationController(rootViewController: oauth)
        self.present(nav, animated: true, completion: nil)
    }
    
    func userWillRegister() {
//        print(#function)
    }
      
    override func viewDidLoad() {
        super.viewDidLoad()

        
        
        
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    // MARK: - Table view data source
}
